md C:\DACFramework

$webclient = New-Object System.Net.WebClient

# Downloading SQLSysClrTypes.msi
$webclient.DownloadFile("http://go.microsoft.com/fwlink/?LinkID=221257&clcid=0x409","C:\DACFramework\SQLSysClrTypes.msi")

# Downloading SharedManagementObjects.msi
$webclient.DownloadFile("http://go.microsoft.com/fwlink/?LinkID=221285&clcid=0x409","C:\DACFramework\SharedManagementObjects.msi")

# Downloading DACFramework.msi
$webclient.DownloadFile("http://go.microsoft.com/fwlink/?LinkID=221306&clcid=0x409","C:\DACFramework\DACFramework.msi")

# Downloading SqlDom.msi
$webclient.DownloadFile("http://go.microsoft.com/fwlink/?LinkID=221302&clcid=0x409","C:\DACFramework\SqlDom.msi")

# Downloading TSqlLanguageService.msi
$webclient.DownloadFile("http://go.microsoft.com/fwlink/?LinkID=221300&clcid=0x409","C:\DACFramework\TSqlLanguageService.msi")

# Install DAC components using Start-Process
try {

$msifile= 'C:\DACFramework\SQLSysClrTypes.msi'
$arguments= ' /qn /l*v C:\DACFramework\install_SQLSysClrTypes.txt' 
Start-Process -file $msifile -arg $arguments -passthru | wait-process

$msifile= 'C:\DACFramework\SharedManagementObjects.msi'
$arguments= ' /qn /l*v C:\DACFramework\install_SharedManagementObjects.txt' 
Start-Process -file $msifile -arg $arguments -passthru | wait-process

$msifile= 'C:\DACFramework\DACFramework.msi'
$arguments= ' /qn /l*v C:\DACFramework\install_DACFramework.txt' 
Start-Process -file $msifile -arg $arguments -passthru | wait-process

$msifile= 'C:\DACFramework\SqlDom.msi'
$arguments= ' /qn /l*v C:\DACFramework\install_SqlDom.txt' 
Start-Process -file $msifile -arg $arguments -passthru | wait-process

$msifile= 'C:\DACFramework\TSqlLanguageService.msi'
$arguments= ' /qn /l*v C:\DACFramework\install_TSqlLanguageService.txt' 
Start-Process -file $msifile -arg $arguments -passthru | wait-process

echo INSTALLATION SUCCESSFULLY COMPLETED >> C:\DACFramework\install_log.txt
}
catch {
echo INSTALLATION ERROR (ERRORLEVEL=%ERRORLEVEL%) >> C:\DACFramework\install_log.txt
}
